<template>
    <el-card class="not-found">
        <template #header>
            <div class="card-header">
                <h1>404 - 页面不存在</h1>
            </div>
        </template>
        <p>将在{{ count }}秒后自动跳转回首页...</p>
        <el-button type="primary" @click="goHome">立即返回首页</el-button>
    </el-card>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { ElCard, ElButton } from 'element-plus'

const router = useRouter()

const count = ref(5)

const goHome = () => {
    router.push('/')
}

const countdown = () => {
    if (count.value > 1) {
        count.value--
        setTimeout(countdown, 1000)
    } else {
        goHome()
    }
}

onMounted(() => {
    setTimeout(countdown, 1000);
})
</script>

<style scoped>
.not-found {
    max-width: 600px;
    margin: 100px auto;
    text-align: center;
}

h1 {
    font-size: 2rem;
    margin-bottom: 20px;
}

p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 30px;
}
</style>
